import ajax from '@/utils/request'

export const getArticle = (channelId, timestamp) => {
  return ajax({
    method: 'GET',
    url: '/app/v1_1/articles',
    // 如果是接口约定是body传参的话使用data
    params: {
      channel_id: channelId,
      timestamp: timestamp,
      with_top: 1
    }
  })
}
// 不喜欢的文章api
export const dislikeArticle = (articleId) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}
// 获取文章详情内容
export const getArticles = (id) => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/articles/' + id
  })
}
// 添加点赞
export const delLike = (target) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/article/likings',
    data: {
      target
    }
  })
}
// 取消点赞
export const addLike = (target) => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/article/likings/' + target
  })
}
// 取消不喜欢文章
export const loveArticle = (target) => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/article/dislikes/' + target
  })
}
// 不喜欢文章
export const hateArticle = (target) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/article/dislikes',
    data: {
      target
    }
  })
}
